package com.yangl.corejava.date;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by yangl on 2018/3/24.
 */
public class Test {
    public static void main(String[] args) {
        /**
         * 实现两个日期之间所有日期的遍历
         */
        Calendar start = Calendar.getInstance();
        start.set(2018, 1, 10);
        Long startTIme = start.getTimeInMillis();

        Calendar end = Calendar.getInstance();
        end.set(2018, 2, 10);
        Long endTime = end.getTimeInMillis();

        Long oneDay = 1000 * 60 * 60 * 24L;

        Long time = startTIme;
        while (time <= endTime) {
            Date d = new Date(time);
            DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            System.out.println(df.format(d));
            time += oneDay;
        }
    }
}
